﻿using ApiManage.Models.zyhModels;
using ApiManage.Service.MsSql.IService;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;

namespace ApiManage.Service.MsSql.Service
{
    public class WorkModuleService : BaseService, IWorkModuleService
    {

        public List<WorkModule> GetList(Expression<Func<WorkModule, bool>> where) => _zyhContext.WorkModule.Where(where).ToList();

        public void Insert(WorkModule param)
        {
            _zyhContext.Add(param);
            _zyhContext.SaveChanges();
        }

        public void Update(WorkModule param)
        {
            var item = _zyhContext.WorkModule.FirstOrDefault(o => o.Id == param.Id);
            item.Name = param.Name;
            item.Description = param.Description;
            item.Status = param.Status;
            item.Sort = param.Sort;
            _zyhContext.SaveChanges();
        }

        public void Delete(int id)
        {
            var User = _zyhContext.WorkModule.FirstOrDefault(o => o.Id == id);
            User.Status = 9;
            _zyhContext.SaveChanges();
        }
    }
}
